﻿namespace GSC.WebControls
{
    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.ComponentModel.Design;
    using System.Drawing.Design;
    /// <summary>
    /// 
    /// </summary>
    class BackgroundCenterLeftMenuButtonControlCollectionEditor : CollectionEditor
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="type"></param>
        public BackgroundCenterLeftMenuButtonControlCollectionEditor(Type type)
            : base(type)
        {
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        protected override bool CanSelectMultipleInstances()
        {
            return false;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        protected override bool CanRemoveInstance(object value)
        {
            //CenterLeftMenuButton item = (CenterLeftMenuButton)value;
            //if (item.HasControls())
            //    return false;
            return true;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        protected override Type CreateCollectionItemType()
        {
            return typeof(BackgroundCenterLeftMenuButtonControl);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
        {
            if (context != null)
                return UITypeEditorEditStyle.Modal;
            return base.GetEditStyle(context);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="itemType"></param>
        /// <returns></returns>
        protected override object CreateInstance(Type itemType)
        {
            BackgroundCenterLeftMenuButtonControl item = base.CreateInstance(itemType) as BackgroundCenterLeftMenuButtonControl;
            //CenterLeftMenuTitle c = (CenterLeftMenuTitle)this.Context.Instance;
            item.Text = item.ID;
            return item;
        }
    }
}